// ignore_for_file: overridden_fields
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../index.dart';

///
///Author: YYF
///Date: 2022-02-06 16:45:11
///Description:
///

/// 检查是否登录
class RouteAuthMiddleware extends GetMiddleware {
  // priority 数字小优先级高
  @override
  int? priority = 0;

  RouteAuthMiddleware({required this.priority});

  @override
  RouteSettings? redirect(String? route) {
    if (UserStore.to.hasToken ||
        // route == AppRoutes.SIGN_IN ||
        // route == AppRoutes.INITIAL ||
        route == AppRoutes.LOGIN) {
      return null;
    } else {
      // Future.delayed(
      //     const Duration(seconds: 1), () => toastInfo(msg: "登录过期,请重新登录"));
      return const RouteSettings(name: AppRoutes.LOGIN);
    }
  }
}
